package com.longrise.co;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.widget.LinearLayout;

import com.ly.common.commonutils.SPUtils;
import com.ly.common.commonwidget.StatusBarCompat;


/**
 * 应用程序启动类：显示欢迎界面并跳转到主界面
 */
public class AppStartActivity extends Activity {

	private static final String TAG = "AppStart";

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		final View view = View.inflate(this, R.layout.activity_start, null);
		LinearLayout wellcome = (LinearLayout) view
				.findViewById(R.id.app_start_view);
		//沉浸状态栏
		StatusBarCompat.translucentStatusBar(this);
		setContentView(view);

		// 渐变展示启动屏
		AlphaAnimation aa = new AlphaAnimation(1.0f, 1.0f);
		aa.setDuration(2000);
		view.startAnimation(aa);
		aa.setAnimationListener(new AnimationListener() {
			@Override
			public void onAnimationEnd(Animation arg0) {
				redirectTo();
			}

			@Override
			public void onAnimationRepeat(Animation animation) {
			}

			@Override
			public void onAnimationStart(Animation animation) {
			}

		});

	}


	/**
	 * 跳转到...
	 */
	private void redirectTo() {
		String userFlag = SPUtils.getSharedStringData(this, "userflag");
		String user = SPUtils.getSharedStringData(this, "user");
		String sign = SPUtils.getSharedStringData(this, "sign");
        String userType = SPUtils.getSharedStringData(this, "userType");
		Intent intent = null;
/*
		if(!StringUtils.isEmpty(userFlag) && !StringUtils.isEmpty(user) && !StringUtils.isEmpty(sign)) {
			CommonPara.getInstance().setUser(user);
			CommonPara.getInstance().setSign(sign);
			CommonPara.getInstance().setUserflag(userFlag);
            CommonPara.getInstance().setUserType(userType);
			//直接跳转首页
			intent = new Intent(this, MainActivity.class);
		} else {
			intent = new Intent(this, LoginActivity.class);
		}*/
		intent = new Intent(this, MainActivity.class);
		startActivity(intent);
		finish();
	}

	@Override
	protected void onDestroy() {
		super.onDestroy();
	}
}